import axios from 'axios'
export default {
  state: {
    kindlist: [],
    brandlist: []
  },
  getters: {
  },
  actions: {
    getkindlist (context) {
      axios.get('/pro/type?type=type').then(res => {
        console.log(res.data)
        context.commit({
          type: 'changeKindlist',
          data: res.data.data
        })
      })
    },
    getbrandlist (context1, data) {
      let arr = []
      console.log(222)
      axios.get('/pro/brand?type=' + data.item).then(res => {
        console.log(res.data.data)
        res.data.data.map(item1 => {
          arr.push(item1.classification)
        })
        console.log(arr)
      })
      context1.commit({
        type: 'changeBrandlist',
        data: arr
      })
    }
  },
  mutations: {
    changeKindlist (state, data) {
      state.kindlist = data.data
    },
    changeBrandlist (state, data) {
      state.brandlist = data.data
      console.log(Array.form(state.brandlist))
    }
  }
}
